////////////////////////////////////////////////////////////
// Workfile : AsciiWriter.cpp
// Author : Thomas Pfeiffer
// Date : 31.10.2012
// Description : Implementation of the AsciiWriter class
//               Extends Writer / implements the template method
////////////////////////////////////////////////////////////
#include "Address.h"
#include "Person.h"
#include "AsciiWriter.h"

void AsciiWriter::DoWrite( std::ostream & out, Address* addr, std::list<Person*> const& persons, 
       bool WriteHeader ) const
{
	if (WriteHeader) {
		out << "Adressen mit zugeordneten personen" << std::endl;
		out << "----------------------------------" << std::endl;
	}

  // Print town and postcode and street and streetnumber in the next row
	out << addr->getTown() << std::endl << addr->getStreetAndNumber() << std::endl;

  // Iterate through all persons and print their names
	std::list<Person*>::const_iterator it = persons.begin();
	for (; it != persons.end(); ++it) {
		out << "\t" << (*it)->getName() << std::endl;	
	}
	out << std::endl;

}
